package com.springStudy.context.annotation.importBeanDefinitionRegistrarDemo;

import com.springStudy.cache.annotation.EnableCachingDemo;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.*;


/**
 * 实现了 ImportBeanDefinitionRegistrar 接口的类通过Import 注解注入到容器中，此时里面的Bean会自动被注入
 */
@Configuration
@ComponentScan("com.springStudy.context.annotation.importBeanDefinitionRegistrarDemo.*")
@Import(FirstImportBeanDefinitionRegistrar.class)
public class ImportBeanDefinitionRegistrarConfigDemo {
    public static void main(String[] args) {
        ApplicationContext context = new AnnotationConfigApplicationContext(ImportBeanDefinitionRegistrarConfigDemo.class);
        String[] beanDefinitionNames = context.getBeanDefinitionNames();
        for (String beanName : beanDefinitionNames) {
            System.out.println(beanName + " : " + context.getBean(beanName));
        }
    }


}
